package com.preparation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.preparation.domain.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PostMapper extends BaseMapper<Post> {

    //修改审核状态
    @Update("update tbl_post set status=#{status} where id=#{id}")
    int updateStatus(Integer id, String status);

    //修改置顶状态
    @Update("update tbl_post set is_sticky=#{isSticky} where id=#{id}")
    int updateIsSticky(Integer id, Integer isSticky);

    //增加浏览量
    @Update("update tbl_post set views_count=views_count+1 where id=#{id}")
    int addViewsCount(Integer id);

    //修改点赞数
    @Update("update tbl_post set likes_count=likes_count+#{count} where id=#{id}")
    int updateLikesCount(Integer id, Integer count);

    //修改评论数
    @Update("update tbl_post set comments_count=comments_count+#{count} where id=#{id}")
    int updateCommentsCount(Integer id, Integer count);

    //修改收藏数
    @Update("update tbl_post set collects_count=collects_count+#{count} where id=#{id}")
    int updateCollectsCount(Integer id, Integer count);

    //修改帖子信息
    @Update("update tbl_post set title=#{title},content=#{content},images=#{images},category_id=#{categoryId} " +
            "where id=#{id}")
    int renewById(Post post);

    //更新热度
    @Update("update tbl_post set hot_value=#{newHotValue} where id=#{id}")
    int updateHotValue(Integer id, Integer newHotValue);

}
